﻿using System.Collections.Generic;

namespace Cms.Domain
{
    public class PluginTemplateLiteral
    {
        private IDictionary<int, PluginTemplateLiteralTranslation> _translations;

        public PluginTemplateLiteral()
        {
            _translations = new Dictionary<int, PluginTemplateLiteralTranslation>();
        }

        public virtual int ID { get; set; }

        public virtual string ControlID { get; set; }

        public virtual IDictionary<int, PluginTemplateLiteralTranslation> Translations
        {
            get { return _translations; }
            set { _translations = value; }
        }

        public virtual PluginTemplate Template { get; set; }

        public virtual string GetHtml(int localeID)
        {
            return _translations.ContainsKey(localeID) ? _translations[localeID].Html : string.Empty;
        }
        
        public virtual void SetHtml(int localeID, string html)
        {
            if (!_translations.ContainsKey(localeID))
            {
                var translation = new PluginTemplateLiteralTranslation();
                translation.Html = html;
                _translations.Add(localeID, translation);
            }
            else
                _translations[localeID].Html = html;
        }
    }
}